using DG.Tweening;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace hole.defaultgame
{
	public class UIGameOverTimer : MonoBehaviour
	{
		[Serializable]
		public class GameOverRank
		{
			public CanvasGroup canvasGroup;

			public Text scoreText;

			public Text pseudoText;

			public Text starText;

			public GameObject localPlayerBackground;
		}

		public Text title;

		public Image background;

		public GameOverRank[] ranks;

		[Header("Continue")]
		public CanvasGroup continueGroup;

		public GameObject continueNormalObject;

		public GameObject continueRVObject;

		public void Show()
		{
			base.gameObject.SetActive(value: true);
			title.rectTransform.anchoredPosition = new Vector2(0f, 130f);
			background.color = new Color(0f, 0f, 0f, 0f);
			GameOverRank[] array = ranks;
			foreach (GameOverRank gameOverRank in array)
			{
				gameOverRank.canvasGroup.alpha = 0f;
			}
			title.rectTransform.DOAnchorPosY(210f, 0.3f).SetDelay(0.5f);
			background.DOFade(0.6f, 0.3f).SetDelay(0.8f);
			float num = 1.3f;
			GameOverRank[] array2 = ranks;
			foreach (GameOverRank gameOverRank2 in array2)
			{
				gameOverRank2.canvasGroup.DOFade(1f, 0.2f).SetDelay(num);
				num += 0.1f;
			}
			continueGroup.interactable = false;
			continueGroup.alpha = 0f;
			continueGroup.DOFade(1f, 0.2f).SetDelay(num + 0.5f).OnComplete(delegate
			{
				continueGroup.interactable = true;
			});
			//if (VoodooServiceLocator.Ads.IsRewardedVideoAvailable() && BaseGameManager.Instance.Reward > 1)
			//{
			//	continueNormalObject.SetActive(value: false);
			//	continueRVObject.SetActive(value: true);
			//}
			//else
			//{
			//	continueNormalObject.SetActive(value: true);
			//	continueRVObject.SetActive(value: false);
			//}
		}

		public void SetLeaderboard(List<Hole> holes)
		{
			for (int i = 0; i < ranks.Length; i++)
			{
				if (i >= holes.Count)
				{
					ranks[i].canvasGroup.gameObject.SetActive(value: false);
					continue;
				}
				ranks[i].canvasGroup.gameObject.SetActive(value: true);
				GameOverRank gameOverRank = ranks[i];
				gameOverRank.scoreText.text = string.Format("{0}{1}", holes[i].Points.ToString(), LocalizationManager.GetTranslation((holes[i].Points >= 2) ? "TXT_GAME_POINTS" : "TXT_GAME_POINT"));
				gameOverRank.pseudoText.text = holes[i].Pseudo;
				gameOverRank.scoreText.color = holes[i].CurrentSkinParameters.mainColor;
				gameOverRank.pseudoText.color = holes[i].CurrentSkinParameters.mainColor;
				gameOverRank.starText.text = GameManager.InstanceMode.GetStarRewardByRank(i).ToString();
				gameOverRank.localPlayerBackground.SetActive(holes[i].IsLocalPlayer);
			}
		}
	}
}
